#include <iostream.h>

/*
 * (C) xiaozhi 2006 wise 5.30 22:12
 */


class l_stack
{
public:
	int data;
	link *next;
	void inistack(l_stack *top);
	void push(l_stack *top, int x);
	void pop(l_stack *top);
	int gettop(l_stack *top);
	bool empty(l_stack *top);
};

void l_stack::inistack(l_stack *top)
{
	top->next = NULL;
}

void l_stack::push(l_stack *top, int x)
{
	l_stack *s;
	s = new l_stack;
	s->data = x;
	s->next = top->next;
	top->next = s;
}

void l_stack::pop(l_stack *top)
{
	l_stack *s;
	s = top->next;
	if (s != NULL)
	{
		top->next = s->next;
		delete(s);
	}
}

int l_stack::gettop(l_stack *top)
{
	if (top->next != NULL)
		return top->next->data;
	else
		return NULL;
}

bool l_stack::empty(l_stack *top)
{
	if (top->next == NULL)
		return (true);
	else
		return (false);
}


